<?php
/**
 * Created by PhpStorm.
 * User: W
 * Date: 2018/12/5
 * Time: 9:47
 */

namespace app\sports_admin\service;
use app\sports_admin\model\TableBar;
use app\sports_admin\model\TableVideo;
use app\sports_admin\model\TableChapter;
use think\Request;

class ExamVideo
{
    //返回中考视频的集合
    public static function compilationVideo()
    {
        return TableVideo::select();
    }
    //返回全部章节
    public static function section($id)
    {
        return TableChapter::where('catid',$id)->field('id,zjtitle,content')->select();
    }
    //展示章节下的全部视频
    public static function videoList($id)
    {
        return TableBar::where('catid',$id)->field('id,zjtitle,url,content,icon_path,introduce')->select();
    }
    //返回合集的全部信息
    public static function gather($id)
    {
        return TableVideo::gather($id);
    }
    //更新集合的信息
    public static function updateGather()
    {
        $data = Request::instance()->only(['id','title','introduce','jsname','icon_path','video_path','city']);
        $content = htmlspecialchars($data['introduce']);
        $id   = $data['id'];
        unset($data['id']);
        return TableVideo::where("id",$id)->update(['title'=>$data['title'],'introduce'=>$content,'jsname'=>$data['jsname'],
            'icon_path'=>$data['icon_path'],'video_path'=>$data['video_path'],'city'=>$data['city']]);
    }
}